<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"
	language="java"%>
<%@ include file="/jsp/platform/include/include.jsp"%>
<html>
<head>
<TITLE><c:out value="${_LOGONUSER_.MANAGETITILE}" /></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<%@ include file="/jsp/platform/include/header.jsp"%>
	<script type="text/javascript">
		    
	</script>
</HEAD>
<BODY>
	<DIV class="all">
		<%@ include file="/jsp/platform/include/head.jsp"%>
		<%@ include file="/jsp/platform/include/menu.jsp"%>
		<DIV class="mains">
			<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
				<TBODY>
					<TR valign="top">
						<%@ include file="/jsp/platform/include/mainLeft.jsp"%>
						<TD>
							<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
								<TBODY>
									<TR>
										<TD>
											<TABLE width="180" border="0" cellspacing="0" cellpadding="0">
												<TBODY>
													<TR>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_l.jpg">
														</TD>
														<TD align="center"
															background="<%=request.getContextPath()%>/images/pages_bg.jpg">
															<SPAN class="f_tit1">商户信息列表</SPAN></TD>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_r.jpg">
														</TD>
													</TR>
												</TBODY>
											</TABLE></TD>
									</TR>
								</TBODY>
								<TR>
									<TD>
										<div class="pages_con">
											<FORM name="queryForm" id="queryForm"
												action="<%=request.getContextPath()%>/manage/merchantInfo/queryMerchantInfoList"
												method="post">
												<div class="pages_con_20">

													<div class="transaction_external">
														<DIV class="clearfix">

															<SPAN class="label dl_w"
																  style="padding-left:20px;text-align:right;">申请时间：</SPAN>
															<DIV class="select2 date">
																<INPUT name="beginDate" class="easyui-datebox"
																	   id="beginDate" style="border:none" type="text"
																	   data-options="formatter:myformatter,parser:myparser"
																	   value="${model.beginDate}">
															</DIV>
															<SPAN class="label margin_l_5">-</SPAN>
															<DIV class="select2 date">
																<INPUT name="endDate" class="easyui-datebox"
																	   id="endDate" style="border:none" type="text"
																	   data-options="formatter:myformatter,parser:myparser"
																	   value="${model.endDate}">
															</DIV>

															<SPAN class="fund-item"><SPAN class="label dl_w"
																style="padding-left: 20px; text-align: right;">商户名称：</SPAN>
																<INPUT name="merchantName" id="merchantName"
																class="txtbox_cz txtbox_cz_long txtbox_cz_color input_change"
																type="text" maxlength="30" value="<c:out value='${model.merchantName}'/>">

															<SPAN class="fund-item"><SPAN class="label dl_w"
																  style="padding-left: 20px; text-align: right;">注册账号：</SPAN>
															      <INPUT name="sysAccount" id="sysAccount"
																  class="txtbox_cz txtbox_cz_long txtbox_cz_color input_change"
																  type="text" maxlength="30" value="<c:out value='${model.sysAccount}'/>">
														</DIV>

														<DIV class="clearfix">

															<SPAN class="fund-item"><SPAN class="label dl_w" style="padding-left: 20px;
																  text-align: right;">所属代理商：</SPAN>
															<INPUT name="agentName" id="agentName"
																   class="txtbox_cz txtbox_cz_long txtbox_cz_color input_change"
																   type="text" maxlength="30"
																   value="<c:out value='${model.agentName}'/>"></SPAN>

													        <SPAN class="fund-item"><SPAN class="label dl_w" style="padding-left:20px;
                                                                      text-align:center;">商户状态：</SPAN>
															  <select id="status" name="status">
															        <option value="">商户状态</option>
                                                                    <option value="0">正常</option>
                                                                    <option value="1">待审核</option>
                                                                    <option value="2">未实名认证</option>
                                                                    <option value="3">审核拒绝</option>
                                                                    <option value="4">禁用</option>
															  </select>
															</SPAN>

															<SPAN class="label dl_w" style="padding-left:50px;">直属商户
															<input type="checkbox" id="isDirect" name="isDirect" value="1"
																   <c:if test="${model.isDirect=='1'}">checked="true"</c:if>></SPAN>
																	
															<SPAN class="fund-item">
																<A class="btn confirm margin_l_10" onClick="$('#queryForm').submit();"
																href="javascript:void(0);">查询</A> </SPAN>
														</DIV>
													</DIV>
													<br>

														<div class="talbes">

															<table style="text-align: center" width="100%" border="0"
																cellpadding="8" cellspacing="0">
																<tbody>
																	<tr class="talbe_pubs_tr">
																		<td>申请时间</td>
																		<td>商户名称</td>
																		<td>注册账号</td>
																		<td>所属代理商</td>
																		<td>商户状态</td>
																		<td>操作</td>
																	</tr>
																	<c:forEach var="model" items="${list}">
																		<tr>
																			<td><fmt:formatDate value="${model.createDate}"
																					pattern="yyyy-MM-dd HH:mm:ss" /></td>
																			<td><c:out value="${model.merchantName}" /></td>
																			<td><c:out value='${model.sysAccount}' /></td>
																			<td><common:GetAccounNameByIdELTag
																					key="${model.agentId}" /></td>
																			<td><c:choose>
																					<c:when test="${model.status == '0'}">正常</c:when>
																					<c:when test="${model.status == '1'}">待审核</c:when>
																					<c:when test="${model.status == '2'}">未实名认证</c:when>
																					<c:when test="${model.status == '3'}">审核拒绝</c:when>
																					<c:when test="${model.status == '4'}">禁用</c:when>
																				</c:choose></td>
																			<td>
																			<A href="javascript:void(0);"
																				onclick="modifyMerchantInfoWindow('${model.merchantId}')">修改</A>
																			<A href="javascript:void(0);"
																				onclick="viewMerchantInfo('${model.merchantId}')">详情</A>
																			<%-- 	<c:if
																					test="${_LOGONUSER_.operatorInfoModel.operatorType != '2'}"> --%>
																				<%--	<A
																						href="<%=request.getContextPath()%>/manage/merchantInfo/editMerchantInfo?merchantId=${model.merchantId}">修改</A>--%>
																					<A href="javascript:void(0);"
																						onclick="limitChange('${model.merchantId}')">T0调额</A>
																					<%--<A href="javascript:void(0);"
																						onclick="resetPassword('${model.merchantId}')">禁用无卡</A>--%>
																					<c:choose>
																						<c:when test="${model.status == '0'}">
																							<A href="javascript:void(0);"
																								onclick="lockMerchant('${model.merchantId}','${model.sysAccount}')">锁定</A>
																						</c:when>
																						<c:when test="${model.status == '4'}">
																							<A href="javascript:void(0);"
																								onclick="unLockMerchant('${model.merchantId}')">解锁</A>
																						</c:when>
																					</c:choose>

																					<A href="javascript:void(0);"
																						onclick="resetPassword('${model.merchantId}')">登陆密码重置</A>
																					<A href="javascript:void(0);"
																						onclick="resetPayPassword('${model.merchantId}')">交易密码重置</A>
																				<%-- </c:if> --%></td>
																		</tr>
																	</c:forEach>

																</tbody>
															</table>
															<jsp:include page="/jsp/platform/include/kkpager.jsp"></jsp:include>
														</div>
												</div>
											</FORM>
										</div> <!--当中内容块结束--></TD>
								</TR>
							</TABLE></TD>
					</TR>
				</TBODY>
			</TABLE>
		</DIV>
		<%@ include file="/jsp/platform/include/foot.jsp"%>
</BODY>
</HTML>
<script type="text/javascript">
function viewMerchantInfo(merchantId) {
		var url = "<%=request.getContextPath()%>/manage/merchantInfo/viewMerchantInfo?merchantId="	+ merchantId;
						var diag = new Dialog();
						diag.Width = 1000;
						diag.Height = 768;
						diag.Title = "详情";
						diag.URL = url;
						diag.show();
					}
function modifyMerchantInfoWindow(merchantId) {
		var url = "<%=request.getContextPath()%>/manage/merchantInfo/modifyMerchantInfoWindow?merchantId="	+ merchantId;
						var diag = new Dialog();
						diag.Width = 1000;
						diag.Height = 768;
						diag.Title = "修改";
						diag.URL = url;
						diag.show();
					}					
function limitChange(merchantId) {
	var url = "<%=request.getContextPath()%>/manage/merchantInfo/limitChangeEdit?merchantId="
							+ merchantId;
					var diag = new Dialog();
					diag.Width = 400;
					diag.Height = 200;
					diag.Title = "T0额度调整";
					diag.URL = url;
					diag.show();
				}
function resetPassword(merchantId){
        $.messager.confirm("操作提示", "您确定要执行操作吗？", function (data) {
            if (data) {
                var url = "<%=request.getContextPath()%>/manage/merchantInfo/resetPassword?merchantId="+merchantId;
				$.ajax({
					async : false,
					type : "POST",
					url : url,
					dataType : 'json',
					success : function(json) {
						if(json.state == "1") {
							$.messager.alert("提示信息", "登陆密码重置成功");
						}else if(json.state == "0") {
							$.messager.alert("提示信息", "登陆密码重置失败");
						}
					}
				});
            }
        });
}	
function lockMerchant(_merchantId,_sysAccount){
    $.messager.confirm("操作提示", "您确定要执行操作吗？", function (data) {
        if (data) {
            var url = "<%=request.getContextPath()%>/manage/merchantInfo/updateMerchantInfo";
            $.post(
                    url,
                    {
                        'merchantId' : _merchantId,
                        'operatorType':'L',
                        'sysAccount':_sysAccount,
                        'status' : '4'//锁定
                    },
                    function(data) {
                        if (data.success) {
                            $.messager.alert("提示信息", data.msg,"info",function(){
					           window.parent.document.location = window.parent.document.location;
					           parentDialog.close();
					        });
                        } else {
                            $.messager.alert("提示信息", data.msg);
                        }
                    });
        }
    });
}	

function unLockMerchant(_merchantId){
    $.messager.confirm("操作提示", "您确定要执行操作吗？", function (data) {
        if (data) {
            var url = "<%=request.getContextPath()%>/manage/merchantInfo/updateMerchantInfo";
            $.post(
                    url,
                    {
                        'merchantId' : _merchantId,
                        'status' : '0'
                    },
                    function(data) {
                        if (data.success) {
                            $.messager.alert("提示信息", data.msg,"info",function(){
					           window.parent.document.location = window.parent.document.location;
					           parentDialog.close();
					        });
                        } else {
                            $.messager.alert("提示信息", data.msg);
                        }
                    });
        }
    });
}


function resetPayPassword(merchantId){
    $.messager.confirm("操作提示", "您确定要执行操作吗？", function (data) {
        if (data) {
            var url = "<%=request.getContextPath()%>/manage/merchantInfo/resetPayPassword?merchantId="+ merchantId;
								$.ajax({
									async : false,
									type : "POST",
									url : url,
									dataType : 'json',
									success : function(json) {
										if (json.state == "1") {
											$.messager
													.alert("提示信息", "交易密码重置成功");
										} else if (json.state == "0") {
											$.messager
													.alert("提示信息", "交易密码重置失败");
										}
									}
								});
							}
						});
	}
	 $("#status").val("<c:out value='${model.status}'/>");
</script>
